//
//  UIBarButtonItem+button.m
//  Weibo
//
//  Created by wpapple on 16/5/30.
//  Copyright © 2016年 wpapple. All rights reserved.
//

#import "UIBarButtonItem+button.h"

@implementation UIBarButtonItem (button)

+(instancetype)itemWithImage:(NSString *)imageName hightImageName:(NSString *)hightImageName target:(id)target action:(SEL)action
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:hightImageName] forState:UIControlStateHighlighted];

    btn.size = btn.currentImage.size;

    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:btn];
    
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    return item;

}
@end
